package com.orangelife.service.feelog.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.orangelife.common.MybaitsGenericDaoSubLogic;
import com.orangelife.exception.AppBizException;
import com.orangelife.service.feelog.IFeeLogService;
import com.orangelife.service.feelog.modal.PropFeeLogDto;
import com.orangelife.utils.IdUtil;


@Service("feeLogService")
public class FeeLogServiceImpl extends MybaitsGenericDaoSubLogic implements
IFeeLogService {

	@Override
	public int addLog(PropFeeLogDto propFeeLogDto) throws AppBizException {
		
		if(propFeeLogDto.getLogID()==null){
			
			propFeeLogDto.setLogID(IdUtil.getuuId());
			
		}
		propFeeLogDto.setItemStat("1");
		propFeeLogDto.setTscreate(new Date());
		// TODO Auto-generated method stub
		return this.getSqlSession().insert("PropFeeLogMapper.insertSelective", propFeeLogDto);

	}

	@Override
	public PropFeeLogDto getLogDetail(String logID) throws AppBizException {
		// TODO Auto-generated method stub
		return this.getSqlSession().selectOne("PropFeeLogMapper.selectByPrimaryKey", logID);

	}

	@Override
	public List<PropFeeLogDto> getLogList(String contentValue,
			String type, String operation) throws AppBizException {
		
		Map<String,Object> param=new HashMap<String,Object>();
		
		param.put("contentValue", contentValue);
		param.put("type", type);
		param.put("operation", operation);
		 List<PropFeeLogDto> l=this.getSqlSession().selectList("PropFeeLogMapper.selectLogList",param) ;
		// TODO Auto-generated method stub
		return l;
		
	}

	@Override
	public int addLog(String commID,String type,String operation,String... param) throws AppBizException {
		
		int len=param.length;
	
		
		
		PropFeeLogDto propFeeLogDto=new PropFeeLogDto();
		propFeeLogDto.setType(type);
		propFeeLogDto.setCommID(commID);
		propFeeLogDto.setOperation(operation);
		propFeeLogDto.setCreateuserID(len>0?param[0]:null);
		propFeeLogDto.setContent(len>1?param[1]:null);
		propFeeLogDto.setContentValue(len>2?param[2]:null);
		propFeeLogDto.setRemark(len>3?param[3]:null);
			propFeeLogDto.setLogID(IdUtil.getuuId());

			propFeeLogDto.setItemStat("1");
			propFeeLogDto.setTscreate(new Date());

			return this.getSqlSession().insert("PropFeeLogMapper.insertSelective", propFeeLogDto);


	}

	

}
